﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
using System.Text;

namespace ThomasGIS.Helpers
{
    public static class DatetimeCalculator
    {
        public static int DatetimeToTimestamp(string datetime, string format)
        {
            DateTime newDatetime = DateTime.ParseExact(datetime, format, CultureInfo.InvariantCulture);
            DateTime startTime = new DateTime(1970, 1, 1);
            return (int)((newDatetime.Ticks / 10000000.0 - startTime.Ticks / 10000000.0));
        }

        public static string TimestampToDatetime(int timestamp, string format)
        {
            DateTime dateTime = new DateTime(timestamp);
            return dateTime.ToString(format);
        }
    }
}
